<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core" >
    <ui:define name="title">
        <h:outputText value="#{bundle.ListStatusTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form id="form" styleClass="form list" rendered="#{userController.allowedGroups('1,2')}">
            <p:fieldset legend="Status Control" >
                <p:commandButton value="New Status" icon="ui-icon-plus" action="#{statusController.prepareCreate}" />
                <p:separator/>
                <p:dataTable id="statuses"
                             styleClass="data"
                             var="sts"
                             rowKey="#{sts}"
                             value="#{statusController.items}"
                             selection="#{statusController.current}"
                             selectionMode="single"
                             rows="8"
                             paginator="#{statusController.items.size() gt 8}"
                             >
                    <f:facet name="header">
                        <h:outputText value="Status List"></h:outputText>
                    </f:facet>
                    <p:column sortBy="#{sts.stsStatus}"  >
                        <f:facet name="header">
                            <h:outputText value="Description"/>
                        </f:facet>
                        <h:outputText value="#{sts.stsStatus}"/>
                    </p:column>
                     <p:column sortBy="#{sts.stsStatus}" style="background-color:##{sts.stsColor}" >
                        <f:facet name="header">
                            <h:outputText value="Color"/>
                        </f:facet>
                         <h:outputText value="#{sts.stsColor}"/>
                    </p:column>
                    <f:facet name="footer">
                        <h:outputText id="rowCount"
                                      value="Total number of records: #{statusController.items.size()}" />
                        <p:commandButton icon="ui-icon-plus" rendered="#{empty statusController.items}" action="#{statusController.prepareCreate}" value="New"/>
                    </f:facet>
                </p:dataTable>
                <p:contextMenu for="statuses" >
                    <p:menuitem value="Edit" icon="ui-icon-pencil"   action="#{statusController.prepareEdit}" />
                    <p:menuitem value="Delete" icon="ui-icon-close" actionListener="#{statusController.destroyAndView}" update="statuses"/>
                    <p:menuitem value="View" icon="ui-icon-search" action="#{statusController.prepareView}"/>
                    <p:menuitem value="New" icon="ui-icon-plus" action="#{statusController.prepareCreate}" />
                </p:contextMenu>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>


